﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Security;

public partial class Account_Final : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int i = 0;
        int p = 0;
        string s;
        Guid user = (Guid)Membership.GetUser().ProviderUserKey;

        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
        SqlCommand cmd = conn.CreateCommand();
        conn.Open();
        cmd.Parameters.Add("@user", SqlDbType.UniqueIdentifier).Value = user;
        DataTable tabla = new DataTable();
        cmd.CommandText = "SELECT * FROM Puntaje where @user=UserId";
        SqlTransaction mytrans = conn.BeginTransaction();
        cmd.Transaction = mytrans;
        cmd.ExecuteNonQuery();
        mytrans.Commit();

        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(tabla);
        while (i < 7)
        {
            p = p + Convert.ToInt32(tabla.Rows[i][3]);
            i++;
        }
        s = Convert.ToString(p);
        conn.Close();
        MostrarResultado.Text = ("El puntaje máximo es 100. Los ultimos juegos son lo que mas valor dan al puntaje. Tu suma es:  " + s);
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Account/Concursos.aspx");
    }
}


